/*
 * SoyEditor.h
 *
 *  Created on: 2012-9-15
 *      Author: yangentao@gmail.com
 */

#ifndef SOYEDITOR_H_
#define SOYEDITOR_H_

#include "../dep.h"
#include "../ed/Document.h"

class Editor: public Window {
	typedef Window Super;
	WindowListenerAdapter adapter;
public:
	Editor();
	virtual ~Editor();
public:
	int getScrollPosH();
	int getScrollPosV();
	void setScrollPosH(int pos);
	void setScrollPosV(int pos);
public:
	bool create(HWND parent, Rect rect);
	void onPaint(HWND w, HDC dc, PAINTSTRUCT* ps);
public:
	void openFile(String filename);
	void setText(String text);
	String getText();

private:
	void drawLine(Canvas& c, int line, String& lineText);
private:

	Document doc;

};

//------------------inline implements-----------------
inline int Editor::getScrollPosH() {
	return GetScrollPos(getWnd(), SB_HORZ);
}
inline int Editor::getScrollPosV() {
	return GetScrollPos(getWnd(), SB_VERT);
}
inline void Editor::setScrollPosH(int pos) {
	SetScrollPos(getWnd(), SB_HORZ, pos, TRUE);
}
inline void Editor::setScrollPosV(int pos) {
	SetScrollPos(getWnd(), SB_VERT, pos, TRUE);
}

#endif /* SOYEDITOR_H_ */
